package top.yeyusmile.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yeyusmile.common.RobotConfig;
import top.yeyusmile.pojo.MyQQMessage;

/**
 * @author 夜雨
 * @Web www.yeyusmile.top
 * @date 2022/3/17 20:03
 */
@Service
public class BlackWordServiceImpl implements BlackWordService {

    @Autowired
    private RobotConfig config;

    @Autowired
    private SendMsgService sendMsgService;

    @Override
    public boolean isBlackWord(MyQQMessage message) {
        if (message != null && !"".equals(message.getMqMsgseq())) {
            if (config.getBlackWord() != null &&
                    config.containBlackWord(message.getMqMsg())) {
                if (config.containGid(message.getMqFromid())) {
                    sendMsgService.withDrawMsg(message);
                    sendMsgService.sendMsg("检测到违禁词", message);
                }
                return true;
            } else {
                return false;
            }
        }
        return false;
    }
}
